//
//  UIView+Extension.m
//  NewsChannal
//
//  Created by chinabyte on 2017/7/18.
//  Copyright © 2017年 chinabyte. All rights reserved.
//

#import "UIView+Extension.h"

@implementation UIView (Extension)
- (CGSize)tt_size
{
    return self.frame.size;
}

- (void)setTt_size:(CGSize)tt_size
{
    CGRect frame = self.frame;
    frame.size = tt_size;
    self.frame = frame;
}

- (CGFloat)tt_width
{
    return self.frame.size.width;
}

- (CGFloat)tt_height
{
    return self.frame.size.height;
}

- (void)setTt_width:(CGFloat)tt_width
{
    CGRect frame = self.frame;
    frame.size.width = tt_width;
    self.frame = frame;
}

- (void)setTt_height:(CGFloat)tt_height
{
    CGRect frame = self.frame;
    frame.size.height = tt_height;
    self.frame = frame;
}

- (CGFloat)tt_x
{
    return self.frame.origin.x;
}

- (void)setTt_x:(CGFloat)tt_x
{
    CGRect frame = self.frame;
    frame.origin.x = tt_x;
    self.frame = frame;
}

- (CGFloat)tt_y
{
    return self.frame.origin.y;
}

- (void)setTt_y:(CGFloat)tt_y
{
    CGRect frame = self.frame;
    frame.origin.y = tt_y;
    self.frame = frame;
}

- (CGPoint)tt_center
{
    return self.center;
}

- (void)setTt_center:(CGPoint)tt_center
{
    self.center = tt_center;
}

- (CGFloat)tt_centerX
{
    return self.center.x;
}

- (void)setTt_centerX:(CGFloat)tt_centerX
{
    CGPoint center = self.center;
    center.x = tt_centerX;
    self.center = center;
}

- (CGFloat)tt_centerY
{
    return self.center.y;
}

- (void)setTt_centerY:(CGFloat)tt_centerY
{
    CGPoint center = self.center;
    center.y = tt_centerY;
    self.center = center;
}

- (CGFloat)tt_right
{
    return CGRectGetMaxX(self.frame);
}

- (CGFloat)tt_bottom
{
    return CGRectGetMaxY(self.frame);
}

- (void)setTt_right:(CGFloat)tt_right
{
    self.tt_x = tt_right - self.tt_width;
}

- (void)setTt_bottom:(CGFloat)tt_bottom
{
    self.tt_y = tt_bottom - self.tt_height;
}

+ (instancetype)viewFromXib
{
    return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
}

@end
